﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for BLLConfirmShipment
/// </summary>
public class BLLConfirmShipment
{
	public BLLConfirmShipment()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public vPackageDetail getPackageInformation(int packageID)
    {
        DALPackageDetail dal = new DALPackageDetail();
        return dal.getPackageDetail(packageID);
    }

    public tblPackage getPackageByBarcode(string barcode)
    {
        DALPackage dal = new DALPackage();
        return dal.getPackage(barcode);
    }

    public void confirmShipment(vPackageDetail vpackage)
    {
        DALPackageStatus dalStatus = new DALPackageStatus();
        DALPackage dalPackage = new DALPackage();
        tblPackage package = dalPackage.getPackage(vpackage.ID);
        package.Status = dalStatus.GetStatus("Ready").ID;
        dalPackage.updatePackage(package);
    }

    public void confirmShipment(int packageid, int currentBranch)
    {
        DALPackageStatus dalStatus = new DALPackageStatus();
        DALTransit dalTransit = new DALTransit();
        DALPackage dalPackage = new DALPackage();

        tblPackage package = dalPackage.getPackage(packageid);
        package.Status = dalStatus.GetStatus("Ready").ID;
        tblTransit transit = new tblTransit()
        {
            BranchID= currentBranch,
            NextTransitID = 0,
            PackageID = package.ID,
            Date = DateTime.Now,
            Status = 0
        };
        dalPackage.updatePackage(package);
        dalTransit.InsertNewTransit(transit);
    }
}